using System.Reflection;

namespace System.Utility.Data.Validation
{
	public class LengthValidatorAttribute : ValidatorAttribute
	{
		private int _MinLength;

		private int _MaxLength;

		public int MaxLength
		{
			get
			{
				return _MaxLength;
			}
			set
			{
				_MaxLength = value;
			}
		}

		public int MinLength
		{
			get
			{
				return _MinLength;
			}
			set
			{
				_MinLength = value;
			}
		}

		public LengthValidatorAttribute() : this(0, 2147483647)
		{
		}

		public LengthValidatorAttribute(int max) : this(0, max)
		{
		}

		public LengthValidatorAttribute(int min, int max)
		{
			_MaxLength = max;
			_MinLength = min;
		}

		public override Validator GetValidator(PropertyInfo propertyInfo)
		{
			Validator lengthValidator = new LengthValidator(ErrorMsg, Text, propertyInfo, MinLength, MaxLength);
			return lengthValidator;
		}
	}
}